Imports DAL
Imports MyClasses
Imports System.Configuration

Public Class frmFinancialYear
    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpbFinYear.Enter
        Call loadCombo()
    End Sub

    Private Sub loadCombo()
        Dim dtyear As DataTable
        Try
            lblcurntyear.Text = DFinancialYear.GetWorkingFinYear(ConfigurationManager.AppSettings("FirmID"))
            dtyear = DFinancialYear.GetAllYears(ConfigurationManager.AppSettings("FirmID"))
            BCommon.SetComboValues(cmbCurrentWorkingYear, dtyear, "FinYrId", "FIN_YEAR_LABEL")
            cmbCurrentWorkingYear.SelectedValue = ConfigurationManager.AppSettings("FinYrId")
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "loadCombo")
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim intResult As Integer = 0
        Try
            btnUpdate.Enabled = False
            If lblcurntyear.Text = cmbCurrentWorkingYear.Text Then
                BCommon.ShowMsgError(10426)
            Else
                Dim frmPrg As New frmProgressBar
                frmPrg.TopMost = True
                frmPrg.MaximumValue = 10
                frmPrg.Show()
                frmPrg.SetProgress(1)
                frmPrg.SetProgress(2)
                frmPrg.SetProgress(5)
                frmPrg.SetProgress(7)
                intResult = DFinancialYear.SaveYear(cmbCurrentWorkingYear.SelectedValue())
                frmPrg.SetProgress(8)
                frmPrg.SetProgress(10)
                frmPrg.HideProgressbar()
                If intResult > 0 Then
                    BCommon.ShowMsgError(10405)
                    Global.System.Windows.Forms.Application.Exit()
                Else
                    BCommon.ShowMsgError(4)
                End If
            End If
            btnUpdate.Enabled = True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnUpdate_Click")
        End Try
    End Sub

    Private Sub frmFinancialYear_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Financial Year")
        e.Cancel = True
    End Sub

    Private Sub frmFinancialYear_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Financial Year")
        End If
    End Sub

    Private Sub frmFinancialYear_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Close()
        'Call BCommon.SetFormStandards(Me, False)
    End Sub
End Class